import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserExamsVO, UserExamsForm, UserExamsQuery } from '@/api/answer/userExams/types';

/**
 * 查询用户考试记录列表
 * @param query
 * @returns {*}
 */

export const listUserExams = (query?: UserExamsQuery): AxiosPromise<UserExamsVO[]> => {
  return request({
    url: '/answer/userExams/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户考试记录详细
 * @param userExamId
 */
export const getUserExams = (userExamId: string | number): AxiosPromise<UserExamsVO> => {
  return request({
    url: '/answer/userExams/' + userExamId,
    method: 'get'
  });
};

/**
 * 新增用户考试记录
 * @param data
 */
export const addUserExams = (data: UserExamsForm) => {
  return request({
    url: '/answer/userExams',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户考试记录
 * @param data
 */
export const updateUserExams = (data: UserExamsForm) => {
  return request({
    url: '/answer/userExams',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户考试记录
 * @param userExamId
 */
export const delUserExams = (userExamId: string | number | Array<string | number>) => {
  return request({
    url: '/answer/userExams/' + userExamId,
    method: 'delete'
  });
};
